<template>
  <!-- 修改窗口 -->
  <a-modal v-model:visible="visible" title="修改用户信息" @ok="execUpd">
    <a-form
      ref="fromRef"
      :model="updObj"
      :label-col="{ span: 5 }"
      :wrapper-col="{ span: 14 }"
    >
      <a-form-item label="电话">
        <a-input v-model:value="updObj.phone_number" />
      </a-form-item>
    </a-form>
  </a-modal>
</template>
<script>

import { ref, reactive } from "vue";
import { put, tip } from "@/common";

export default {

  setup(props, { emit }) {
    const fromRef = ref();
    const updObj = reactive({
      cust_username:"",
      phone_number: "",
    });
    const visible = ref(false);

    const open = (record) => {
      updObj.cust_username = record.cust_username;
      updObj.phone_number = record.phone_number;
      console.log("record"+record);
      visible.value = true;
    };

    const execUpd = () => {
      //执行修改
      put("/security/user", updObj).then((res) => {
        emit("ok");
        updObj.cust_username = "";
        updObj.phone_number = "";
        visible.value = false;
        tip.success("修改客户信息成功！");
      });
    };

    return {
      updObj,
      visible,
      execUpd,
      open,
      fromRef,
    };
  },
};
</script>
<style scoped>
</style>